<div *ngIf="driver" class="form-horizontal">
    <form #driverform="ngForm" novalidate>
    <div class="row">
        <div class="form-group col-sm-6">
            <label for="id" class="form-control-label">ID:</label>
            <input name="id" id="id" [(ngModel)]="driver.driver_id" placeholder="司机ID" class="form-control" required readonly />
        </div>
        <div class="form-group col-sm-6">
            <label for="name" class="form-control-label">司机姓名:</label>
            <input name="driver_name" #driver_name="ngModel" id="name" [(ngModel)]="driver.driver_name" placeholder="司机姓名" class="form-control" required />
            <span style="color:red" [hidden]="driver_name.valid || driver_name.pristine">
                姓名不能为空。
            </span>
        </div>
    </div>
    <div class="row">
        <div class="form-group col-sm-6">
            <label for="mobile" class="form-control-label">电话:</label>
            <input name="driver_mobile" #driver_mobile="ngModel" id="mobile" [(ngModel)]="driver.driver_mobile" placeholder="电话" class="form-control" 
            required pattern="(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$"/>
            <span style="color:red" [hidden]="driver_mobile.valid || driver_mobile.pristine">
                电话格式不正确。
            </span>
        </div>
        <div class="form-group col-sm-6">
            <label for="carrier" class="form-control-label">所属公司:</label>
            <select name="carrier_id" class="form-control" id="carrier" required [(ngModel)]="driver.carrier_id" name="carrier" disabled>
                <option *ngFor="let carrier of carriers" [value]="carrier.carrier_id">{{carrier.carrier_name}}</option>
            </select>
        </div>
    </div>
    <div class="row">
        <div class="form-group col-sm-6">
            <label for="status" class="form-control-label">是否有效:</label>
            <select name="status" class="col-sm-10 form-control" id="status" [(ngModel)]="driver.status">
                <option>YES</option>
                <option>NO</option>
            </select>
        </div>
    </div>
    <div class="row">
        <div class="form-group">
            <!--<div class="col-sm-1">
                <button class="btn btn-danger" *ngIf="driver.driver_id" (click)="delete()">删除</button>
            </div>-->
            <div class="offset-sm-6 col-sm-1">
                <button class="btn btn-default" *ngIf="driver.driver_id" (click)="resetPassword()">重置密码
                <span *ngIf="driver.password" class="label label-danger">{{driver.password}}</span>
                </button>
            </div>
            <div class="offset-sm-2 col-sm-1">
                <button class="btn btn-default" (click)="cancel()">取消</button>
            </div>
            <div class="col-sm-1">
                <button [disabled]="!driverform.form.valid" class="btn btn-primary" (click)="save()">保存</button>
            </div>
        </div>
    </div>
    </form>
</div>
